﻿using Grow.Module.Service;
using Hangfire;

namespace Grow.Scheduler.Hangfire
{
    public class GrowJobActivator : JobActivator
    {
        private readonly IServiceContext _serviceContext;

        public GrowJobActivator(IServiceContext serviceContext)
        {
            _serviceContext = serviceContext;
        }

        public override object ActivateJob(Type type)
        {
            IServiceContext serviceContext = _serviceContext.GetServiceContext();
            return serviceContext.GetRequiredService(type);
        }
    }
}
